# python 装饰器
def decortor(func):
    def inter():
        print("hello")
        print("hello")
        print("hello")
        r = func()
        print("end")
        print("end")
        print("end")
        return r
    # func()
    return inter
@decortor
# 当函数执行到这里的时候 把@后面的函数名执行 并且把将其下面的函数 名作为参赛执行
# 并且把的decortor的函数返回值给fun1
def fu1():
    print("fu1")
fu1()
# 装饰器 有参数的情况
def outer(func):
    def inner(a,b):
        print("原函数执行前")
        ret = func(a,b)
        print("原函数执行后")
        return ret
    return inner
@outer
def func1(a,b):
    print("func1执行")
    return a + b
ret = func1(1,3)
print(ret)
# 装饰器万能参数
def outer(func):
    def inner(*args, **kargs):
        print(args, kargs)
        r = func(*args, **kargs)
        print("end")
        return r

    return inner


@outer
def fun(a, b):
    return a + b


@outer
def fun1(args):
    print(args)
    return None


@outer
def fun2(args, args1, args2):
    print(args, args1, args2)


r = fun(1, 2)
print(r)
一个函数可以拥有多个装饰器
def outer_one(func):
    def inner(*args,**kargs):
        print("我是第一个装饰器")
        r = func(*args, **kargs)
        return r

    return inner


def outer(func):
    def inner(*args, **kargs):
        print("begin")
        r = func(*args, **kargs)
        print("end")
        return r

    return inner


@outer_one
@outer
def fun(a,b):
    print("我是函数")
    return a + b
r = fun(1,2)
print(r)